home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / i-cporte.ads < prev    next >
Text File  |  1996-01-30  |  10KB  |  260 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                I N T E R F A C E S . C . P O S I X _ R T E               --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.7 $                             --
  10. --                                                                          --
  11. --       Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved        --
  12. --                                                                          --
  13. -- GNARL is free software; you can redistribute it  and/or modify it  under --
  14. -- terms  of  the  GNU  Library General Public License  as published by the --
  15. -- Free Software  Foundation;  either version 2, or (at  your  option)  any --
  16. -- later  version.  GNARL is distributed  in the hope that  it will be use- --
  17. -- ful, but but WITHOUT ANY WARRANTY;  without even the implied warranty of --
  18. -- MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. -- eral Library Public License  for more details.  You should have received --
  20. -- a  copy of the GNU Library General Public License along with GNARL;  see --
  21. -- file COPYING.LIB.  If not,  write to the  Free Software Foundation,  675 --
  22. -- Mass Ave, Cambridge, MA 02139, USA.                                      --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  This package interfaces with the POSIX real-time extensions. It may
  27. --  also implement some of them using UNIX operations. It is not a complete
  28. --  interface, it only includes what is needed to implement the Ada runtime.
  29.  
  30. with System;
  31.  
  32. --  temporarily, should really only be for 1 ???
  33. with Interfaces.C.POSIX_Error; use Interfaces.C.POSIX_Error;
  34. --  Used for, Return_Code
  35.  
  36. with Interfaces.C.POSIX_Constants;
  37. --  Used for, various constants
  38.  
  39. package Interfaces.C.POSIX_RTE is
  40.  
  41.    --  The following definitions are from P1003.5,
  42.    --  which the rest of this package is not.
  43.  
  44.    type Signal is new int;
  45.  
  46.    type Signal_Set is private;
  47.  
  48.    procedure Signal_Add
  49.      (Set : in out Signal_Set;
  50.       Sig : in Signal);
  51.  
  52.    procedure  Signal_Add_All (Set : in out Signal_Set);
  53.  
  54.    procedure Signal_Delete
  55.      (Set : in out Signal_Set;
  56.       Sig : in Signal);
  57.  
  58.    procedure Signal_Delete_All (Set : in out Signal_Set);
  59.  
  60.    function Member_Of
  61.      (Set : Signal_Set;
  62.       Sig : Signal)
  63.      return Boolean;
  64.  
  65.    type sigval is record
  66.       u0 : int;
  67.    end record;
  68.    --  This is not used at the moment, need to update to reflect
  69.    --  any changes in the Pthreads signal.h in the future
  70.  
  71.    type struct_siginfo is record
  72.       si_signo : Signal;
  73.       si_code : int;
  74.       si_value : sigval;
  75.    end record;
  76.  
  77.    type siginfo_ptr is access struct_siginfo;
  78.  
  79.    type sigset_t_ptr is access Signal_Set;
  80.  
  81.    SIG_ERR : constant := POSIX_Constants.SIG_ERR;
  82.    SIG_DFL : constant := POSIX_Constants.SIG_DFL;
  83.    SIG_IGN : constant := POSIX_Constants.SIG_IGN;
  84.    --  constants for sa_handler
  85.  
  86.    type struct_sigaction is record
  87.  
  88.       sa_handler : System.Address;
  89.       --  address of signal handler
  90.  
  91.       sa_mask : Signal_Set;
  92.       --  Additional signals to be blocked during
  93.       --  execution of signal-catching function
  94.  
  95.       sa_flags : int;
  96.       --  Special flags to affect behavior of signal
  97.  
  98.    end record;
  99.  
  100.    type sigaction_ptr is access struct_sigaction;
  101.  
  102.    --  Signal catching function (signal handler) has the following profile :
  103.  
  104.    --  procedure Signal_Handler
  105.    --    (signo   : Signal;
  106.    --     info    : siginfo_ptr;
  107.    --     context : sigcontext_ptr);
  108.  
  109.    SA_NOCLDSTOP : constant := POSIX_Constants.SA_NOCLDSTOP;
  110.    --  Don't send a SIGCHLD on child stop
  111.  
  112.    SA_SIGINFO : constant := POSIX_Constants.SA_SIGINFO;
  113.    --  sa_flags flags for struct_sigaction
  114.  
  115.    SIG_BLOCK   : constant := POSIX_Constants.SIG_BLOCK;
  116.    SIG_UNBLOCK : constant := POSIX_Constants.SIG_UNBLOCK;
  117.    SIG_SETMASK : constant := POSIX_Constants.SIG_SETMASK;
  118.    --  sigprocmask flags (how)
  119.  
  120.    type jmp_buf is array
  121.      (1 .. POSIX_Constants.pthread_jmp_buf_size) of unsigned;
  122.    for jmp_buf'Alignment use 8;
  123.  
  124.  
  125.    type sigjmp_buf is array
  126.      (1 .. POSIX_Constants.pthread_sigjmp_buf_size) of unsigned;
  127.    for sigjmp_buf'Alignment use 8;
  128.  
  129.    type jmp_buf_ptr is access jmp_buf;
  130.  
  131.    type sigjmp_buf_ptr is access sigjmp_buf;
  132.    --  Environment for long jumps
  133.  
  134.    procedure sigaction
  135.      (sig    : Signal;
  136.       act    : struct_sigaction;
  137.       oact   : out struct_sigaction;
  138.       Result : out Return_Code);
  139.    pragma Inline (sigaction);
  140.    --  install new sigaction structure and obtain old one
  141.  
  142.    procedure sigaction
  143.      (sig    : Signal;
  144.       act    : sigaction_ptr;
  145.       oact   : out struct_sigaction;
  146.       Result : out Return_Code);
  147.    pragma Inline (sigaction);
  148.    --  Same thing as above, but pass the pointer instead. By passing null
  149.    --  pointer we can find out the action associated with it.
  150.    --  WE WANT TO MAKE THIS VERSION TO INCLUDE THE PREVIOUS sigaction.
  151.    --  TO BE FIXED LATER ???
  152.  
  153.    procedure sigprocmask
  154.      (how    : int;
  155.       set    : Signal_Set;
  156.       oset   : out Signal_Set;
  157.       Result : out Return_Code);
  158.    pragma Inline (sigprocmask);
  159.    --  Install new signal mask and obtain old one
  160.  
  161.    procedure sigprocmask
  162.      (how    : int;
  163.       set    : sigset_t_ptr;
  164.       oset   : out Signal_Set;
  165.       Result : out Return_Code);
  166.    pragma Inline (sigprocmask);
  167.    --  Same thing as above, but pass the pointer instead. By passing null
  168.    --  pointer we can find out the current mask associated with it.
  169.    --  WE WANT TO MAKE THIS VERSION TO INCLUDE THE PREVIOUS sigprocmask.
  170.    --  TO BE FIXED LATER ???
  171.  
  172.    procedure sigsuspend
  173.      (mask : Signal_Set;
  174.       Result : out Return_Code);
  175.    pragma Inline (sigsuspend);
  176.    --  Suspend waiting for signals in mask and resume after
  177.    --  executing handler or take default action
  178.  
  179.    procedure sigpending
  180.      (set : out Signal_Set;
  181.       Result : out Return_Code);
  182.    pragma Inline (sigpending);
  183.    --  get pending signals on thread and process
  184.  
  185.    procedure longjmp (env : jmp_buf; val : int);
  186.    pragma Inline (longjmp);
  187.    --  execute a jump across procedures according to setjmp
  188.  
  189.    procedure siglongjmp (env : sigjmp_buf; val : int);
  190.    pragma Inline (siglongjmp);
  191.    --  execute a jump across procedures according to sigsetjmp
  192.  
  193.    procedure setjmp (env : jmp_buf; Result : out Return_Code);
  194.    pragma Inline (setjmp);
  195.    --  set up a jump across procedures and return here with longjmp
  196.  
  197.    procedure sigsetjmp
  198.      (env      : sigjmp_buf;
  199.       savemask : int;
  200.       Result   : out Return_Code);
  201.    pragma Inline (sigsetjmp);
  202.    --  Set up a jump across procedures and return here with siglongjmp
  203.  
  204.    SIGKILL                     : constant Signal := POSIX_Constants.SIGKILL;
  205.    SIGSTOP                     : constant Signal := POSIX_Constants.SIGSTOP;
  206.    --  Signals which cannot be masked
  207.  
  208.    --  Some synchronous signals (cannot be used for interrupt entries)
  209.  
  210.    SIGALRM                     : constant Signal := POSIX_Constants.SIGALRM;
  211.  
  212.    SIGILL                      : constant Signal := POSIX_Constants.SIGILL;
  213.    SIGFPE                      : constant Signal := POSIX_Constants.SIGFPE;
  214.    SIGSEGV                     : constant Signal := POSIX_Constants.SIGSEGV;
  215.  
  216.    SIGABRT                     : constant Signal := POSIX_Constants.SIGABRT;
  217.  
  218.    --  Signals which can be used for Interrupt Entries.
  219.  
  220.    SIGHUP                      : constant Signal := POSIX_Constants.SIGHUP;
  221.    SIGINT                      : constant Signal := POSIX_Constants.SIGINT;
  222.    SIGQUIT                     : constant Signal := POSIX_Constants.SIGQUIT;
  223.    SIGPIPE                     : constant Signal := POSIX_Constants.SIGPIPE;
  224.    SIGTERM                     : constant Signal := POSIX_Constants.SIGTERM;
  225.    SIGUSR1                     : constant Signal := POSIX_Constants.SIGUSR1;
  226.    SIGUSR2                     : constant Signal := POSIX_Constants.SIGUSR2;
  227.    SIGCHLD                     : constant Signal := POSIX_Constants.SIGCHLD;
  228.    SIGCONT                     : constant Signal := POSIX_Constants.SIGCONT;
  229.    SIGTSTP                     : constant Signal := POSIX_Constants.SIGTSTP;
  230.    SIGTTIN                     : constant Signal := POSIX_Constants.SIGTTIN;
  231.    SIGTTOU                     : constant Signal := POSIX_Constants.SIGTTOU;
  232.  
  233.    --  SunOS specific signals
  234.  
  235.    --  SunOS synchronous signals
  236.  
  237.    SIGEMT                      : constant Signal := POSIX_Constants.SIGEMT;
  238.    SIGBUS                      : constant Signal := POSIX_Constants.SIGBUS;
  239.    SIGTRAP                    : constant Signal := POSIX_Constants.SIGTRAP;
  240.  
  241.  
  242.    --  SunOS signals which can be used for Interrupt Entries
  243.  
  244.    SIGSYS                     : constant Signal := POSIX_Constants.SIGSYS;
  245.    SIGURG                     : constant Signal := POSIX_Constants.SIGURG;
  246.    SIGIO                      : constant Signal := POSIX_Constants.SIGIO;
  247.    SIGXCPU                    : constant Signal := POSIX_Constants.SIGXCPU;
  248.    SIGXFSZ                    : constant Signal := POSIX_Constants.SIGXFSZ;
  249.    SIGVTALRM                  : constant Signal := POSIX_Constants.SIGVTALRM;
  250.    SIGPROF                    : constant Signal := POSIX_Constants.SIGPROF;
  251.    SIGWINCH                   : constant Signal := POSIX_Constants.SIGWINCH;
  252.    SIGLOST                    : constant Signal := POSIX_Constants.SIGLOST;
  253.  
  254. private
  255.    type Signal_Set is array
  256.       (1 .. POSIX_Constants.posix_sigset_t_size) of unsigned;
  257.    for Signal_Set'Alignment use 8;
  258.  
  259. end Interfaces.C.POSIX_RTE;
  260.